package cool.taomu.toolkit.apilog.test

import cool.taomu.toolkit.Taomu
import javax.ws.rs.GET
import javax.ws.rs.POST
import javax.ws.rs.Path
import org.junit.jupiter.api.Test
import com.google.inject.AbstractModule
import javax.inject.Inject
import cool.taomu.box.UserController2

@Path("/user")
class UserController {

    @GET
    @Path("/list")
    def String list() {
        return "User List";
    }

    @POST
    @Path("/create")
    def String create() {
        return "User Created";
    }
}

class ApiLogTest {

    @Inject
    UserController ctrl;

    @Inject
    UserController2 ctrl2;

    @Test
    def void a() {
        var injector = Taomu.run()
        /*.createChildInjector(new AbstractModule(){
         * 	override configure(){
         * 		bind(UserController)
         * 	}
         })*/
        var t = injector.getInstance(ApiLogTest);
        // 调用几次 API
        println(t.ctrl.list());
        println(t.ctrl.list());
        println(t.ctrl.list());
        println(t.ctrl.create());
        println(t.ctrl2.list());

        while (true) {
            Thread.sleep(10000)
        }
    }
}
